/////////////////////////////////////////////////////////////////////////////
// Name:        SetupWizard.cpp
// Purpose:     
// Author:      yospaly
// Modified by: 
// Created:     05/01/2010 09:38:01
// RCS-ID:      
// Copyright:   Copyright (C) 2008, yospaly
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
#include "WelcomePage.h"
#include "RootdirPage.h"
#include "LocaldirPage.h"
#include "MirrorlistPage.h"
#include "DownloadIniPage.h"
////@end includes

#include "SetupWizard.h"
#include "DownloadIniDialog.h"

////@begin XPM images
#include "wizard.xpm"
////@end XPM images


/*!
 * SetupWizard type definition
 */

IMPLEMENT_DYNAMIC_CLASS( SetupWizard, wxWizard )


/*!
 * SetupWizard event table definition
 */

BEGIN_EVENT_TABLE( SetupWizard, wxWizard )

////@begin SetupWizard event table entries
////@end SetupWizard event table entries

END_EVENT_TABLE()


/*!
 * SetupWizard constructors
 */

SetupWizard::SetupWizard()
{
    Init();
}

SetupWizard::SetupWizard( wxWindow* parent, wxWindowID id, const wxPoint& pos )
{
    Init();
    Create(parent, id, pos);
}


/*!
 * SetupWizard creator
 */

bool SetupWizard::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos )
{
////@begin SetupWizard creation
    SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxWIZARD_EX_HELPBUTTON);
    wxBitmap wizardBitmap(GetBitmapResource(wxT("wizard.png")));
    wxWizard::Create( parent, id, _("Cygwin Setup Wizard"), wizardBitmap, pos, wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX );

    CreateControls();
////@end SetupWizard creation
    return true;
}


/*!
 * SetupWizard destructor
 */

SetupWizard::~SetupWizard()
{
////@begin SetupWizard destruction
////@end SetupWizard destruction
}


/*!
 * Member initialisation
 */

void SetupWizard::Init()
{
////@begin SetupWizard member initialisation
    p_welcome_page = NULL;
    p_rootdir_page = NULL;
    p_localdir_page = NULL;
    p_mirrors_page = NULL;
    p_download_ini_page = NULL;
////@end SetupWizard member initialisation
}


/*!
 * Control creation for SetupWizard
 */

void SetupWizard::CreateControls()
{    
////@begin SetupWizard content construction
    SetupWizard* itemWizard1 = this;

    p_welcome_page = new WelcomePage( itemWizard1 );

    p_rootdir_page = new RootdirPage( itemWizard1 );
    itemWizard1->GetPageAreaSizer()->Add(p_rootdir_page);

    p_localdir_page = new LocaldirPage( itemWizard1 );
    itemWizard1->GetPageAreaSizer()->Add(p_localdir_page);

    p_mirrors_page = new MirrorlistPage( itemWizard1 );
    itemWizard1->GetPageAreaSizer()->Add(p_mirrors_page);

    p_download_ini_page = new DownloadIniPage( itemWizard1 );
    itemWizard1->GetPageAreaSizer()->Add(p_download_ini_page);

    wxWizardPageSimple* lastPage = NULL;
    if (lastPage)
        wxWizardPageSimple::Chain(lastPage, p_welcome_page);
    lastPage = p_welcome_page;
    if (lastPage)
        wxWizardPageSimple::Chain(lastPage, p_rootdir_page);
    lastPage = p_rootdir_page;
    if (lastPage)
        wxWizardPageSimple::Chain(lastPage, p_localdir_page);
    lastPage = p_localdir_page;
    if (lastPage)
        wxWizardPageSimple::Chain(lastPage, p_mirrors_page);
    lastPage = p_mirrors_page;
    if (lastPage)
        wxWizardPageSimple::Chain(lastPage, p_download_ini_page);
    lastPage = p_download_ini_page;
////@end SetupWizard content construction

    itemWizard1->GetPageAreaSizer()->Add(p_welcome_page);
}


/*!
 * Runs the wizard.
 */

bool SetupWizard::Run()
{
    wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
    while (node)
    {
        wxWizardPage* startPage = wxDynamicCast(node->GetData(), wxWizardPage);
        if (startPage) return RunWizard(startPage);
        node = node->GetNext();
    }
    return false;
}


/*!
 * Should we show tooltips?
 */

bool SetupWizard::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap SetupWizard::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin SetupWizard bitmap retrieval
    wxUnusedVar(name);
    if (name == _T("wizard.png"))
    {
        wxBitmap bitmap(wizard_xpm);
        return bitmap;
    }
    return wxNullBitmap;
////@end SetupWizard bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon SetupWizard::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin SetupWizard icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end SetupWizard icon retrieval
}


/*!
 * DownloadIniPage type definition
 */

IMPLEMENT_DYNAMIC_CLASS( DownloadIniPage, wxWizardPageSimple )


/*!
 * DownloadIniPage event table definition
 */

BEGIN_EVENT_TABLE( DownloadIniPage, wxWizardPageSimple )

////@begin DownloadIniPage event table entries
////@end DownloadIniPage event table entries

END_EVENT_TABLE()


/*!
 * DownloadIniPage constructors
 */

DownloadIniPage::DownloadIniPage()
{
    Init();
}

DownloadIniPage::DownloadIniPage( wxWizard* parent )
{
    Init();
    Create( parent );
}


/*!
 * MirrorlistPage1 creator
 */

bool DownloadIniPage::Create( wxWizard* parent )
{
////@begin DownloadIniPage creation
    wxBitmap wizardBitmap(wxNullBitmap);
    wxWizardPageSimple::Create( parent, NULL, NULL, wizardBitmap );

    CreateControls();
    if (GetSizer())
        GetSizer()->Fit(this);
////@end DownloadIniPage creation
    return true;
}


/*!
 * DownloadIniPage destructor
 */

DownloadIniPage::~DownloadIniPage()
{
////@begin DownloadIniPage destruction
////@end DownloadIniPage destruction
}


/*!
 * Member initialisation
 */

void DownloadIniPage::Init()
{
////@begin DownloadIniPage member initialisation
    p_download_ini_panel = NULL;
////@end DownloadIniPage member initialisation
}


/*!
 * Control creation for MirrorlistPage1
 */

void DownloadIniPage::CreateControls()
{    
////@begin DownloadIniPage content construction
    DownloadIniPage* itemWizardPageSimple39 = this;

    wxBoxSizer* itemBoxSizer40 = new wxBoxSizer(wxVERTICAL);
    itemWizardPageSimple39->SetSizer(itemBoxSizer40);

    wxBoxSizer* itemBoxSizer41 = new wxBoxSizer(wxHORIZONTAL);
    itemBoxSizer40->Add(itemBoxSizer41, 0, wxGROW, 5);

    wxBoxSizer* itemBoxSizer42 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer41->Add(itemBoxSizer42, 1, wxALIGN_CENTER_VERTICAL, 5);

    wxStaticText* itemStaticText43 = new wxStaticText( itemWizardPageSimple39, wxID_STATIC, _("Progress"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticText43->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxBOLD, false, wxT("Tahoma")));
    itemBoxSizer42->Add(itemStaticText43, 0, wxALIGN_LEFT|wxALL, 5);

    wxStaticText* itemStaticText44 = new wxStaticText( itemWizardPageSimple39, wxID_STATIC, _("This page displays the progress of the download or installation"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticText44->Wrap(350);
    itemBoxSizer42->Add(itemStaticText44, 0, wxALIGN_LEFT|wxLEFT, 20);

    wxStaticBitmap* itemStaticBitmap45 = new wxStaticBitmap( itemWizardPageSimple39, wxID_STATIC, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
    itemBoxSizer41->Add(itemStaticBitmap45, 0, wxALIGN_CENTER_VERTICAL|wxALL, 20);

    wxStaticLine* itemStaticLine46 = new wxStaticLine( itemWizardPageSimple39, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
    itemBoxSizer40->Add(itemStaticLine46, 0, wxGROW|wxALL, 5);

    p_download_ini_panel = new DownloadIniPanel( itemWizardPageSimple39, ID_MIRRORLISTPANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
    itemBoxSizer40->Add(p_download_ini_panel, 1, wxGROW|wxALL, 5);

////@end DownloadIniPage content construction
}


/*!
 * Should we show tooltips?
 */

bool DownloadIniPage::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap DownloadIniPage::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin DownloadIniPage bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end DownloadIniPage bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon DownloadIniPage::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin DownloadIniPage icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end DownloadIniPage icon retrieval
}
